/**
 * @file ui_about_detail.c
 * @author your name (you@domain.com)
 * @brief ui about detail
 * @version 0.1
 * @date 2023-06-17
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#include "ui_about_detail.h"
#include "msg_event_config.h"
#include "ui_info_list.h"

static ui_basic_com_t s_ui_about_detail = {0};
static bool s_already_init = false;
static lv_obj_t *bg_obj = NULL;
 
 

static int ui_about_detail_enter(int arg0, int arg1, void *arg3)
{
    if(s_already_init)
    {
       return -1;
    }
    s_already_init = true;

    lv_disp_t *d_disp = lv_disp_get_default();
    lv_color_t bg_color = {0};
    bg_color = lv_color_hex(HOME_UI_BG_COLOR);
    bg_obj = lv_obj_create(lv_scr_act());
    lv_obj_set_style_pad_top(bg_obj, 0, 0);
    lv_obj_set_style_pad_bottom(bg_obj, 0, 0);
    lv_obj_set_style_pad_left(bg_obj, 0, 0);
    lv_obj_set_style_pad_right(bg_obj, 0, 0);
    lv_obj_set_size(bg_obj, d_disp->driver->hor_res, d_disp->driver->ver_res);
    lv_obj_set_pos(bg_obj, 0,  0);
    lv_obj_set_style_bg_color(bg_obj, bg_color, 0);
    //lv_obj_set_style_bg_opa(bg_obj, LV_OPA_100, 0);
    lv_obj_set_style_radius(bg_obj, 0, 0);
    lv_obj_set_style_border_width(bg_obj, 0, 0);
    //lv_obj_add_flag(bg_obj, LV_OBJ_FLAG_SCROLL_CHAIN_VER);
    lv_obj_clear_flag(bg_obj, LV_OBJ_FLAG_SCROLLABLE);
    lv_obj_clear_flag(lv_scr_act(), LV_OBJ_FLAG_SCROLLABLE);
    

    lv_obj_t *list = ui_info_list_create(bg_obj, "About");
    ui_info_item_add_to_list(list, APP_NAME_KEY, APP_NAME);
    ui_info_item_add_to_list(list, APP_VER_KEY, APP_VER);
    ui_info_item_add_to_list(list, "Version", APP_VER);
    ui_info_item_add_to_list(list, "Version", APP_VER);
    ui_info_item_add_to_list(list, "Version", APP_VER);
    ui_info_item_add_to_list(list, "Version", APP_VER);
    return 0;
}

static int ui_about_detail_loop(int arg0, int arg1, void *arg3)
{
    if(!s_already_init)
    {
       return -1;
    }

    return 0;
}

static int ui_about_detail_exit(int arg0, int arg1, void *arg3)
{
    if(!s_already_init)
    {
       return -1;
    }
    
    s_already_init = false;

    lv_obj_del(bg_obj);

    return 0;
}

static void ui_about_detail_event(char *event_name, void *data, int srcId)
{
 
}

ui_basic_com_t *ui_about_detail_create(void)
{
    s_ui_about_detail.ui_id = EASY_UI_ABOUT_DETAIL;
    memcpy(s_ui_about_detail.ui_name, EASY_UI_NAME(EASY_UI_ABOUT_DETAIL), strlen(EASY_UI_NAME(EASY_UI_ABOUT_DETAIL)));
    s_ui_about_detail.enter = ui_about_detail_enter;
    s_ui_about_detail.run = ui_about_detail_loop;
    s_ui_about_detail.exit = ui_about_detail_exit;
    return &s_ui_about_detail;
}